[SUBROUTINE]
version = 1.14
icon = lathe-facing.png
name = _("Facing")
type = facing
help = _("<b>Face end and optionnaly set this face to 0.0</b>&#10; Verify cutter orientation")
order = act hx b_x e_x hz sz zu_s zugc lr hf fin ht t

[PARAM_ACT]
name = _("Active")
icon = enable.png
type = bool
value = 1

[PARAM_HX]
name = _("X axis")
type = sub-header

[PARAM_B_X]
name = _("Begin diameter")
type = float
icon = x.png
value = 1.0
metric_value = 25.0
minimum_value = 0.0
not_allowed = 0
header = hx

[PARAM_E_X]
name = _("End diameter")
type = float
icon = x-end.png
value = 0.0
metric_value = 0.0
header = hx

[PARAM_HZ]
name = _("Z axis")
type = sub-header

[PARAM_SZ]
name = _("Begin")
icon = z.png
type = combo-user
options = _("User defined=0:Current position=1:G-Code=2")
value = 1
tool_tip = _("Pre or user defined")
header = hz
links = zu_s=0:zugc=2

[PARAM_ZU_S]
type = float
value = 0.0
metric_value = 0.0
header = hz
hidden = 1

[PARAM_ZUGC]
type = gcode
value =
header = hz
hidden = 1

[PARAM_LR]
name = _("End offset")
icon = dx.png
type = float
value = -0.03
metric_value = -0.75
tool_tip = _("Length to remove")
header = hz

[PARAM_HF]
name = _("Finishing")
type = sub-header

[PARAM_FIN]
name = _("Number of passes")
icon = finish.png
type = int
value = 1
minimum_value = 0
tool_tip = _("Or spring passes")
header = hf

[PARAM_HT]
name = _("Touch off")
type = sub-header

[PARAM_T]
name = _("Set Z to 0")
icon = 00.png
type = bool
header = ht
value = 1
tool_tip = _("Set finished face to Z0")

[VALIDATION]
content =
	if #param_act == 1 :
		if self.check_hash('#param_b_x', 1) < self.check_hash('#param_e_x', 0) :
			self.msg_inv(_('Begin X must be greater than End X'), 1)
			VALIDATED = False
	
		lr = self.check_hash('#param_lr', 0)
		if lr < 0.0 and TOOL_TABLE.get_tool_orient() not in [0, 2, 3, 7, 9] :
			self.msg_inv(_('Cutter orientation should be 7, 2, 9, 3 or 0'), 2)
		elif lr > 0.0 and TOOL_TABLE.get_tool_orient() not in [0, 1, 4, 5, 9] :
			self.msg_inv(_('Cutter orientation should be 5, 1, 9, 4 or 0'), 2)
	
[CALL]
content =
	(begin #sub_name)
	(author : Fernand Veilleux)
	
	o<#self_id_act> if [#param_act]
		o<select>  CALL [42] [#param_sz] [#param_zu_s] [#<_z>] [#param_zugc]
		
		o<facing> CALL [#param_b_x] [#param_e_x] [#42] [#42 + #param_lr] [#param_fin] [#param_t]
		
	o<#self_id_act> endif
	
	(end #sub_name)
	
